<template>
  <div class="container">
    <div>
      <span>这里用来查询垃圾分类</span>
      <div style="display:flex;justify-content:flex-start;align-items:center;margin-top:20px;">
        <el-input v-model="content" placeholder="请输入你是什么垃圾" style="width:40%"></el-input>
        <el-button type="primary" style="margin-left:20px;" @click="action">发送</el-button>
      </div>
    </div>
    <div style="margin-top:20px">
      {{result}}
    </div>
  </div>
</template>

<script>
import { garbage } from '@/common/common'

export default {
  data() {
    return {
      content:'',
      result:''
    }
  },
  methods:{
    action(){
      if(this.content == ''){
        this.$message.error("请输入你是什么垃圾");
        return;
      }
      let params = {
        content:this.content
      }
      garbage(params).then((res) => {
        if(res.status == 200){
          let content = JSON.parse(res.data.body)
          this.result = content.sort
        }
      })
      .catch((err) => {
        console.log(err);
      })
    }
  }
}
</script>

<style>
.container {
  width: 100%;
  padding: 1%;
  margin: 0 auto;
}
</style>
